package datastructure;

import java.util.Deque;
import java.util.LinkedList;

public class 用两个栈实现队列_剑指offer09{
            Deque<Integer> stackPush;
            Deque<Integer> stackPop;
            public 用两个栈实现队列_剑指offer09() {
                stackPush = new LinkedList<>();
                stackPop = new LinkedList<>();

            }
            
            public void appendTail(int value) {
                stackPush.push(value);
            }
            
            public int deleteHead() {
                if(stackPop.isEmpty()) {
                   while(!stackPush.isEmpty()) {
                       // pop栈空了就要全部倒进来 否则顺序就乱了
                       stackPop.push(stackPush.pop());
                   } 
                }
                return stackPop.isEmpty()? -1 : stackPop.pop();
            }
        }
